/*
 * @Description: 分盒按钮
 * @Author: Rfan
 * @Date: 2022-06-17 19:46:09
 * @LastEditTime: 2022-06-24 18:43:38
 */

import { Button, Modal } from 'antd';
import { useLevelTableContext } from '@/components/LevelTable/contexts/LevelTableContext';
import { IUnpackBoxParams } from '@/api/box/boxMgt';

const UnpackBox = () => {
  const { selectItems, baseInfo } = useLevelTableContext();

  const unpackBox = () => {
    Modal.confirm({
      title: '拆盒',
      content: '是否确认拆盒？',
      onOk() {
        const params: IUnpackBoxParams = {
          archiveTypeId: baseInfo.archiveTypeId,
          commonParams: {
            dbName: baseInfo.dbName
          },
          entryIdList: selectItems,
          level: baseInfo.level
        };
        console.log('onOk', params);
        // unpackBoxMethod(params);
      },
      onCancel() {
        console.log('Cancel');
      }
    });
  };

  return (
    <>
      <Button
        type="text"
        disabled={selectItems.length !== 1}
        onClick={() => {
          unpackBox();
        }}
      >
        从盒中拆离
      </Button>
    </>
  );
};

export default UnpackBox;
